package com.syg.Listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;

/**
 * 监听request请求对象的创建,销毁(即监听生命周期)
 */
public class _01_Request_Listener implements ServletRequestListener{

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
        logger.info("requestDestroyed()==>"+"request对象销毁了");
        logger.info("requestDestroyed()==>"+servletRequestEvent.getServletRequest().getAttribute("en"));
    }

    @Override
    public void requestInitialized(ServletRequestEvent servletRequestEvent) {
        logger.info("requestInitialized()==>"+"request对象创建以后,执行初始化方法");
        logger.info("requestInitialized()==>"+servletRequestEvent.getServletRequest().getAttribute("en"));
    }
}
